package com.ch.mobilesha.tools;

import android.content.Context;
import android.telephony.TelephonyManager;

import com.ch.mobilesha.base.MobileShaApplication;
import com.ch.mobilesha.bean.PhoneInfoBean;

public class PhoneTools {
	
	private static TelephonyManager telMgr;
	public static PhoneInfoBean getPhoneInfo(){
		PhoneInfoBean result =new PhoneInfoBean();
		result.setTableName("baseinfo");
		result.setCreateTime(DateHelper.getNow());
		telMgr =(TelephonyManager) MobileShaApplication.getSelf().getSystemService(Context.TELEPHONY_SERVICE);
		if(telMgr.getSimState()==TelephonyManager.SIM_STATE_READY){
			result.setSimState("良好");
		}else if(telMgr.getSimState()==TelephonyManager.SIM_STATE_ABSENT){
			result.setSimState("无sim卡");
		}else{
			result.setSimState("sim卡被锁定或未知状态");
		}
		result.setSimNumber(telMgr.getSimSerialNumber());
		result.setSimOperator(telMgr.getSimOperator());
		result.setSimOperatorName(telMgr.getSimOperatorName());
		result.setSimCountry(telMgr.getSimCountryIso());
		if(telMgr.getPhoneType()==TelephonyManager.PHONE_TYPE_CDMA){
			result.setPhoneType("CDMA");
		}else if(telMgr.getPhoneType()==TelephonyManager.PHONE_TYPE_GSM){
			result.setPhoneType("GSM");
		}
		result.setPhoneNum(telMgr.getLine1Number());
		result.setPhoneIMEI(telMgr.getDeviceId());
		result.setSimIMSI(telMgr.getSubscriberId());
		return result;
	}
}
